/*
 * @Author: xiawei 1243162387@qq.com
 * @Date: 2024-04-01 14:21:57
 * @LastEditors: xiawei 1243162387@qq.com
 * @LastEditTime: 2024-12-11 23:24:54
 */

import { defineStore } from 'pinia';
import { AppsType } from '@/types/index'
const microAppStore = defineStore('microAppStore',{
    state: () => ({ 
        // 显示子应用加载状态
        loading: true as Boolean,
        // 保存系统全量子应用
        originApps: [
            {
                name: 'vue2-app',
                entry: '//localhost:4001',
                container: '#microAppContainer',
                activeRule: '/microApp/vue2-app', 
                code: '/microApp/vue2-app',
            },
            {
                name: 'setting-app',
                entry: '//localhost:4003',
                container: '#microAppContainer',
                activeRule: '/microApp/vue3-vite-app', 
                code: '/microApp/vue3-vite-app',
            }
        ] as AppsType,
        //  当前用户可用子应用
        userApps: [] as AppsType
    }),
    actions: {
        changeLoading(status: Boolean){
            this.loading = status
        },
        // 根据用户权限获取当前用户可以使用的子应用
        addUserMicroApps(){
            // this.userApps = this.originApps.filter(app => menus.includes(app.code))
            this.userApps = this.originApps
        },
        // 清空数据
        clearUserMicroApps(){
            this.userApps = [] as AppsType;
        }

    }

})
export default microAppStore